<?php

  $allowed_page = true;

  function __autoload($className) {
    if (!isset($allowed_page)) { $allowed_page = true; }
	require_once("lib/config.php");
	require_once(CLASS_PATH."{$className}.class.php");
  }

  
  $mail = new Mail();
		session_start();
		
		if(isset($_GET['mail_id'])) {			
			switch($_GET['action']) {
					case "delete":
						$mail->delete($_GET['mail_id']);
					break;
			}
		 }
  
        //Retrieving fields.
		
		if(isset($_SESSION['engine'])&& isset($_POST['to'])) {
		$from = $_SESSION['engine']->getCharacter()->getcharacterId();
        $to = addslashes($_POST['to']);
        $subject = addslashes($_POST['subject']);
        $text = addslashes($_POST['text']);
        $message=$mail->create( $from,$to, $text, $subject);
			
		
		}
			
		
		
		
			
		If($message=="1"){
				$message = "Thanks, We will deliver your mail immediately"	;	
		}

			
			
		
        
	
      

  
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link type="text/css" rel="stylesheet" href="../css/portal.css">
  <title>D5Power WebGame Engine - 用户中心</title>
  
</script>

<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
</head>


<body>

<div id="main_top">
</div>


<div id="container_principal">

  <div id="textura_lateral_esquerda">

	<!-- INÍCIO - Menu lateral -->
	<div class="menu">
	  <div class="menu_esquerda"></div>
	  <div class="menu_direita"></div>
	  <div class="menu_inferior"></div>
	  <div class="menu_superior"></div>

	  <p class="itens_menu">
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="index.php">主页</a></b><br>

	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
  
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="login.php">登录</a></b><br>

	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
  
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="register.php">注册新帐户</a></b><br>
  
	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
	  </p>
	</div>
	<!-- FIM - Menu lateral -->

    
    <div id="barra_lateral_esquerda">
    </div>

  </div>
  <!-- fim do quadro textura lateral -->
     

	<!-- Início do quadro main -->
    <div id="main">
    	
		<!-- INÍCIO - Quadro do formulário -->
		<div class="form_header">
			<p><img style="vertical-align: middle;" src="../pictures/portal/header_left.gif"> Mail:</p>
		</div>
		
		<div class="form_square">
		  <div class="lateral_esquerda"></div>
		  <div class="lateral_direita"></div>
		  <div class="linha_inferior"></div>
		  <div class="linha_superior"></div>
		  <div style="padding: 10px;">

	        <p style="text-align: center;">
			  <b>Mail service</b></p>

        	<form method="POST" name="register" action="mail.php">
	
              <p align="center" style="text-align: left; text-indent: 152px;">
              	To:
                  <span id="sprytextfield1">
                  <input style="size ="20"; maxlength="18;" type="text" name="to" id="user" class="text">
              <span class="textfieldRequiredMsg">required.</span></span>           	  </p>
              <p style="text-align: left; text-indent: 152px;">Subject:
              <span id="sprytextfield2">
              <input name="subject"" type="text" class="text" id="pwd" style="size =" size="40""; maxlength="32"20 ;>
              <span class="textfieldRequiredMsg"> required.</span></span>              </p>
              <p style="text-align: left; text-indent: 152px;">              Message</p>	
			  
			  <p align="center" style="text-align: left; text-indent: 152px;"><span id="sprytextarea1">
              <textarea name="text" id="text" cols="45" rows="5"></textarea>
              <span class="textareaRequiredMsg">required.</span><span class="textareaMaxCharsMsg">Max 255 characters.</span></span></p>
			  <div align="center">
			    <input type="submit" value="Send" name="button" class="button">
			    </p>
			    
			    </p>
		      </div>
			  <p style="text-align: center;">
              	<font size="2" color="#ff1010">
              	
                                    <?php
				
					
					
                      if (isset($message)) {print($message);}
                    ?>
				</font>
			  </p>
			  
	        </form>

		  </div>
		  
		</div>
		<!-- FIM - Quadro de login -->  		
		<div class="received_mail">
		  <div class="lateral_esquerda"></div>
		  <div class="lateral_direita"></div>
		  <div class="linha_inferior"></div>
                  <div class="linha_superior"></div>

		  <div style="padding: 10px;">

	            <p style="text-align: center;">
			<b>Received<br><br><br><br><br><br><br><br><br><br><br><br><br></b></p>

        	    <p align="center" style="text-align: left; text-indent: 152px;"><font size="2" color="#ff1010">

              	    <?php
			$mail->listMailAsTable($_SESSION['engine']->getCharacter()->getcharacterId());
				
                    ?>
		    </font>
		    </p>
		</div>
	      </div>

		  
	
		<!-- FIM - Quadro de login -->  		
    </div>
	<!-- fim do quadro main -->


    <div id="textura_lateral_direita">
      <div id="barra_lateral_direita">
      </div>
    </div>
    
    
</div>

<script type="text/javascript">
<!--
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {maxChars:255});
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
//-->
</script>
</body>

</html>
